package com.itheima.mystream;

import java.util.Map;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Demo9 {
    public static void main(String[] args) {
        String[] strArray = {"林青霞,30", "张曼玉,35", "王祖贤,33", "柳岩,25"};
        Stream<String> arrayStream = Stream.of(strArray).filter(new Predicate<String>() {
            @Override
            public boolean test(String s) {
                String[] split = s.split(",");
                boolean b = Integer.parseInt(split[1]) > 25;
                return b;
            }
        });
        //s -> s.split(",")[0]表示的是:s:每一个字符,将每一个字符进行分割,然后把1索引和2索引进行添加到集合.一定要记住
        Map<String, String> collect = arrayStream.collect(Collectors.toMap(s -> s.split(",")[0], s -> s.split(",")[1]));
        //arrayStream.collect(Collectors.toMap(s -> s.split(",")[0], s -> Integer.parseInt(s.split(",")[1])));
    }
}
